]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspaceThumbnail: Expose maxThumbnailScale as property
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 11 Aug 2023 22:32:35 +0000 (00:32 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 6 Sep 2023 11:35:10 +0000 (11:35 +0000)
Some extensions want to modify the value of the MAX_THUMBNAIL_SCALE
constant. That is no longer possible, as exports are always read-only
from the outside.

Make this possible again by exposing the scale as a property on the
object itself, so extensions can override it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2939>

js/ui/overviewControls.js
js/ui/workspaceThumbnail.js
js/ui/workspacesView.js

index f5ef4334736d41ab40908e4422b26f29d6d6f338..615b4b40b9dd28daf26d25c4bc4b27ba353e315d 100644 (file)
@@ -195,7 +195,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
                 this._workspacesThumbnails.get_preferred_height(width);
             thumbnailsHeight = Math.min(
                 thumbnailsHeight * expandFraction,
-                height * WorkspaceThumbnail.MAX_THUMBNAIL_SCALE);
+                height * this._workspacesThumbnails.maxThumbnailScale);
             childBox.set_origin(0, startY + searchHeight + spacing);
             childBox.set_size(width, thumbnailsHeight);
             this._workspacesThumbnails.allocate(childBox);
index e56acecbe49ab88eeb9e0bde51a170222d453838..75db8111be07393e406885991263d249f15c0430 100644 (file)
@@ -615,6 +615,7 @@ export const ThumbnailsBox = GObject.registerClass({
         this.add_actor(this._dropPlaceholder);
         this._spliceIndex = -1;
 
+        this._maxThumbnailScale = MAX_THUMBNAIL_SCALE;
         this._targetScale = 0;
         this._scale = 0;
         this._expandFraction = 1;
@@ -675,6 +676,10 @@ export const ThumbnailsBox = GObject.registerClass({
             () => this._updateIndicator(), this);
     }
 
+    get maxThumbnailScale() {
+        return this._maxThumbnailScale;
+    }
+
     setMonitorIndex(monitorIndex) {
         this._monitorIndex = monitorIndex;
     }
@@ -1198,7 +1203,7 @@ export const ThumbnailsBox = GObject.registerClass({
         const avail = forWidth - totalSpacing;
 
         let scale = (avail / nWorkspaces) / this._porthole.width;
-        scale = Math.min(scale, MAX_THUMBNAIL_SCALE);
+        scale = Math.min(scale, this._maxThumbnailScale);
 
         const height = Math.round(this._porthole.height * scale);
         return themeNode.adjust_preferred_height(height, height);
@@ -1223,7 +1228,7 @@ export const ThumbnailsBox = GObject.registerClass({
                 workspaceSpacing += spacing / 2;
 
             const progress = 1 - thumbnail.collapse_fraction;
-            const width = (this._porthole.width * MAX_THUMBNAIL_SCALE + workspaceSpacing) * progress;
+            const width = (this._porthole.width * this._maxThumbnailScale + workspaceSpacing) * progress;
             return accumulator + width;
         }, 0);
 
@@ -1290,10 +1295,10 @@ export const ThumbnailsBox = GObject.registerClass({
         const thumbnailHeight = thumbnailFullHeight * this._expandFraction;
         const roundedVScale = thumbnailHeight / portholeHeight;
 
-        // We always request size for MAX_THUMBNAIL_SCALE, distribute
+        // We always request size for maxThumbnailScale, distribute
         // space evently if we use smaller thumbnails
         const extraWidth =
-            (MAX_THUMBNAIL_SCALE * portholeWidth - thumbnailWidth) * nWorkspaces;
+            (this._maxThumbnailScale * portholeWidth - thumbnailWidth) * nWorkspaces;
         box.x1 += Math.round(extraWidth / 2);
         box.x2 -= Math.round(extraWidth / 2);
 
index cddb40904ee8adb74fa18c5eb16cbc52ae1762be..5d58542f976b8ae1206c9320e0d20ad59c894dc9 100644 (file)
@@ -15,7 +15,7 @@ import * as OverviewControls from './overviewControls.js';
 import * as SwipeTracker from './swipeTracker.js';
 import * as Util from '../misc/util.js';
 import * as Workspace from './workspace.js';
-import {ThumbnailsBox, MAX_THUMBNAIL_SCALE} from './workspaceThumbnail.js';
+import {ThumbnailsBox} from './workspaceThumbnail.js';
 
 const WORKSPACE_SWITCH_TIME = 250;
 
@@ -651,7 +651,7 @@ class SecondaryMonitorDisplay extends St.Widget {
         const [thumbnailsHeight] = this._thumbnails.get_preferred_height(width);
         return Math.min(
             thumbnailsHeight * expandFraction,
-            height * MAX_THUMBNAIL_SCALE);
+            height * this._thumbnails.maxThumbnailScale);
     }
 
     _getWorkspacesBoxForState(state, box, padding, thumbnailsHeight, spacing) {